package com.xp.code.util;

import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.persistence.Query;

import com.xp.code.jpa.DefaultJPADAO;

public class CommonConfig extends DefaultJPADAO implements Serializable {

	private static final long serialVersionUID = 5121160368331615724L;
	public static Map<String, String> currentConfig = new HashMap<String, String>();
	private static CommonConfig ccfing=null;
	public CommonConfig() {
		Query query = this.getEntityManager().createNativeQuery("SELECT PARCODE,PARVALUE FROM TSYS_PARAMETER WHERE PARFLAG='0'");
		List<Object[]> list=query.getResultList();
		for(Object[] obj:list){
			currentConfig.put(obj[0].toString(), obj[1].toString());
		}
	}
	
	public static CommonConfig getInstance(){
		if(ccfing==null){
			ccfing=new CommonConfig();
		}
		return ccfing;
	}

	public static void getCommonConfig() {
		currentConfig.put("info", "xxmxx");
	}

	public static String getConfigInfo(String varname) {
		return currentConfig.get(varname);
	}
}
